Java bro

Java tutorial

Sql queries

Get current date with timestamp in sql

In this article we wre going to learn how to get timestamp in different formats.

24.Hrs time format:

SELECT TO_CHAR (SYSDATE, ‘MM-DD-YYYY HH24:MI:SS’) AS CUR_TIME FROM DUAL;

Output :

CUR_TIME
03-07-2016 16:27:56


12.Hrs time format:

SELECT TO_CHAR (SYSDATE, ‘MM:DD:YYYY HH12:MI:SS:AM’) AS CUR_TIME FROM DUAL;

Output :

CUR_TIME
03:07:2016 05:17:01:PM


Comments are Closed

Theme by Anders Norén