![]() ![]() For future date, specify interval value 2 hours from the current timestamp: now() + interval ‘2 hour’.For example, the below SQL query gives the following values. You can also specify an interval for returning the date after a specified period. Now()-Orderdate as Interval FROM SalesOrders For example, the query below returns the interval between the current timestamp and from the SalesOrders table. You can use the minus (-) operator to calculate the difference between two dates. SELECT TO_CHAR(NOW() :: DATE, 'dd-mm-yyyy') You can combine TO_CHAR() and the Now() function to convert the current timestamp into the specified format. You can specify double colons (::) to cast a DATETIME value to a DATE value. The Now() function returns the current system timestamp (date and time). To_char(OrderDate,'DDD MM/DD/YYYY') As "DDD MM/DD/YYYY" To_char(OrderDate,'DAY MM/DD/YYYY') As "MM/DD/YYYY", To_char(OrderDate,'MM/DD/YYYY') As "MM/DD/YYYY", To_char(OrderDate,'DD.MM.YY') As "DD.MM.YY", To_char(OrderDate,'DD-MM-YYYY') As DDMMYYYY, SELECT Orderdetails,OrderDate as ExistingDateformat, Month abbreviation in all capital, first letter capitalized and all lowercase letters, respectivelyĭay name in all capital, first letter capitalized and all lowercase letters, respectivelyĭay of the week (Sunday (1) to Saturday (7))Ī few examples of different date formats are specified in the following SQL. ![]() Month name with the first letter capitalized The supported values in the to_char() function are as shown below. To_char(OrderDate,'DD-MM-YYYY') As NewDateFormat FROM SalesOrders ![]() ![]() The following query converts existing date values stored in the table into DD-MM-YYYY format.
0 Comments
Leave a Reply. |