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?
simflex
Member
80 Points
277 Posts
Why does my date keep incrementing by 100?
May 04, 2012 01:47 PM|LINK
Greetings experts,
on my markup, I have this:
<td> DATE RECEIVED<br /> <asp:TextBox ID="dateReceived" runat="server" Width="146px" /> </td>Then on pageload() event of codebehind, I assigned dateReceived current date:
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
grundebar
Contributor
4515 Points
726 Posts
Re: Why does my date keep incrementing by 100?
May 04, 2012 01:54 PM|LINK
You should use DateTime.Now.toString("yyyyMMdd"). Lowercase m is minutes, not months.
Remeber to Mark as Answer if this post helped you.
simflex
Member
80 Points
277 Posts
Re: Why does my date keep incrementing by 100?
May 04, 2012 02:04 PM|LINK
Man, I feel so stupid. I should have known that!!!
Thank you very much.