Solved

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

Posted on 2011-03-21
3
570 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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