Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 04, 2012 02:04 PM by simflex
May 04, 2012 01:47 PM|LINK
on my markup, I have this:
DATE RECEIVED<br />
<asp:TextBox ID="dateReceived" runat="server" Width="146px" />
Then on pageload() event of codebehind, I assigned dateReceived current date:
dateReceived.Text = System.DateTime.Now.ToString()
On buttonClick event, I formatted the date:
Dim receiveddate As String = dateReceived.Text
receiveddate = DateTime.Now.ToString("yyyymmdd")
Finally, I cocatenated the date value with the letter "C" and 7 digit number generated randomly using generateCode () function. It now looks like this:
Dim contact as String = (receiveddate&"C"&generateCode())
This gives the following value 20120504C0000000
That is yyyymmddC0000000
We then insert this value into the db.
The issue that I am having is that date value keeps increasing by 100.
For instance, after the initial insert into the db, I get the correct date, say 20120504.
Next insert changes 5 to 6 giving the result 20120604. This craziness continues.
Any ideas what I am doing wrong and how to fix it?
Many thanks in advance
May 04, 2012 01:54 PM|LINK
You should use DateTime.Now.toString("yyyyMMdd"). Lowercase m is minutes, not months.
May 04, 2012 02:04 PM|LINK
Man, I feel so stupid. I should have known that!!!
Thank you very much.