August 29, 2005 at 1:17 am
Greetings,
I would like to compare the LastUpdatedDate column of a table with the time the data was read from the front end to make sure no changes are being overwritten. However, when I pass the data from the vb.net front end program to the stored procedure they do not match up although the row of data has not been changed. How can I pass a date from VB.Net to SQL server so that it will look like '2000-05-08 12:35:29.998' . In VB.NET the date looks like 2000-05-08 12:35:29 PM .
Any help would be greatly appreciated.
August 29, 2005 at 1:42 am
The date does not need to 'look like' any special format. Use a command parameter with type specified to datetime when passing the date. That way you do not need to think about formatting yourself.
August 29, 2005 at 12:26 pm
Thanks for your reply Chris but that is what I am doing. I'll just keep trying.
August 29, 2005 at 2:38 pm
What does your VB code look like? And the procedure that you are calling?
August 30, 2005 at 4:52 am
Your date in SQL Server is a datetime datatype and by default VB.NET doe snot pass in teh milliseconds. In order to pass in milliseconds you need to use Date.ToString("yyyy-MM-dd hh:mm:ss.fff"). This should help with your compare. If you do not need the millisecods and seconds you could convert to smalldatetime in SQL Server.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 30, 2005 at 10:31 am
maybe you could just have a default of getdate() in your stored procedure and then do the comparison...this way you only have to call the procedure and not pass any parameters ?!?!
**ASCII stupid question, get a stupid ANSI !!!**
August 30, 2005 at 11:39 pm
The VB .NET have millisecond in the FCL(framework class library) 1.1 Calendar class. When you get less than complete datetime in SQL Server make sure you are not using Small Datetime its resolution is less than Datetime. Try the link below for the .NET Calendar class. Hope this helps.
http://authors.aspalliance.com/aspxtreme/sys/globalization/calendarclass.aspx
Kind regards,
Gift Peddie
Kind regards,
Gift Peddie
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply