Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default systemdate from ymd to dmy

Can somebody help me to change the default systemdate from ymd to dmy? These must be for always the default format !! How?

like image 646
Rachid Avatar asked May 19 '11 06:05

Rachid


People also ask

How do I change the date format from Ymd to DMY?

Change YYYY-MM-DD to DD-MM-YYYY $newDate = date("d-m-Y", strtotime($orgDate));

How do I change Ymd to DMY in Excel?

1. Select a blank cell next to your date, for instance. I1, and type this formula =TEXT(G1, "yyyy-mm-dd"), and press Enter key, then drag AutoFill handle over the cells needed this formula. Now all dates are converted to texts and shown as yyyy-mm-dd format.


1 Answers

SET DATEFORMAT:

Sets the order of the month, day, and year date parts for interpreting date, smalldatetime, datetime, datetime2 and datetimeoffset character strings.

[Note: This is often not the way to solve the problem of interpreting dates. Datetimes should not be stored a strings if you can avoid it (use a datetime or date column instead). If you have to store in a string form, use an ISO 8601 format which is basically of the form YYYYMMDD ]

Example from MSDN:

-- Set date format to day/month/year.
SET DATEFORMAT dmy;
GO
DECLARE @datevar datetime2 = '31/12/2008 09:01:01.1234567';
SELECT @datevar;
GO
-- Result: 2008-12-31 09:01:01.123
SET DATEFORMAT dmy;
GO
DECLARE @datevar datetime2 = '12/31/2008 09:01:01.1234567';
SELECT @datevar;
GO
-- Result: Msg 241: Conversion failed when converting date and/or time -- from character string.
GO
like image 67
Mitch Wheat Avatar answered Oct 04 '22 10:10

Mitch Wheat