• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

how to convert date to be allways MDY for insert to SQL

Hi Experts

i have business layer in C# with property for each column, some of them are date.
i need to insert in one format to database MDY.
how do i configure the property set to set allways the date by MDY,
consider that the OS can be UK or US ???
i don't know in the application which OS sent me the date...

10x a lot
0
gudidi
Asked:
gudidi
  • 2
1 Solution
 
morguloCommented:
The formatting is used only if you change date to string and string to date. Dates stored in database are in binary format, independed from formatting. If you want see dates in specific format in your app you must format dates (when converting to string) in app using local settings - date.ToString(IFormatProvider)
0
 
mayank_joshiCommented:
use

Formate(testDate,"MDY")

Open in new window


where testDate is Date or DateTime datatype.
0
 
mayank_joshiCommented:
sorry use:-

      

Format(testDate,"Mdyy")

Open in new window

or      

Format(testDate,"Mdyyyy")

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now