Solved

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

Posted on 2011-03-21
3
564 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
Comment Utility
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
Comment Utility
use

Formate(testDate,"MDY")

Open in new window


where testDate is Date or DateTime datatype.
0
 
LVL 9

Expert Comment

by:mayank_joshi
Comment Utility
sorry use:-

      

Format(testDate,"Mdyy")

Open in new window

or      

Format(testDate,"Mdyyyy")

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

13 Experts available now in Live!

Get 1:1 Help Now