Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have an VB.net program which stores date and time as one of the date to the sql table.

i use

VB
date.today


the program is converted to exe and many pcs use it. The problem here is different pc has different time and date formats. When i take report on daily basis the report misses many data.

for example i take report on daily basis by

populate all items where date =
VB
date.today
. if the format is different it ignores the data. it search the data with my system format.

How to over come this??
Posted

1 solution

Your whole approach is wrong. Date/time is the universal notion and does not really have any different formats. The formats come into play if you try to store data in the form of strings. You should not. When it comes to databases, store this time data using DATE datatype, which actually represent a point in time, not just date (so the name of type is confusing). And you will need strings only if you want to present date/time on screen, but then you can use appropriate formatting:
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^],
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

(See also all other System.DateTime.ToString/Parse/TryParse/ParseExact/TryParseExact methods.)

Generally, the trend to work with string representing data instead of data itself is a very common beginner's problem these days. Don't repeat this mistake, try to work with data.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900