Headder AdSence

how to get pm/am datetime in T-SQL server


SELECT GETDATE() ActualDateTime,FORMAT(GETDATE(),'MM/dd/yyyy HH:mm:ss tt') TransformedDateTime;


 

how to get first day of month in snowflake

 we have a function in the snowflake, that will truncate the month/year from the given date.


here are few examples.

1. Using Current_Date function

SELECT CURRENT_DATE() AS Today_Date,DATE_TRUNC(MONTH,CURRENT_DATE()) AS Start_Date;

Output: 



2. By using Hardcoded Value

SELECT '2021-05-26' AS Actual_Date,DATE_TRUNC(MONTH,TO_DATE('2021-05-26')) AS Start_Date;


OutPut: