Solved

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

Posted on 2011-03-21
3
566 Views
Last Modified: 2013-12-17
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
Comment
Question by:gudidi
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
morgulo earned 500 total points
ID: 35186907
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
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35186911
use

Formate(testDate,"MDY")

Open in new window


where testDate is Date or DateTime datatype.
0
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35186933
sorry use:-

      

Format(testDate,"Mdyy")

Open in new window

or      

Format(testDate,"Mdyyyy")

Open in new window

0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now