The following is the syntax of TO_CHAR method – We can get the dates in the format we want by converting the default format value of date present in yyyy-mm-dd to another format we wish to by using to_char function. We can use:: double colons to retrieve only the date part from the above output along with date keyword in the following way – If we fire the SELECT NOW() command it will result in – Now() function retrieves the full string of current date and time. We can either use the CURRENT_DATE variable and select its value of use Now() function to retrieve the current date and i,e and further to only retrieve date use Now():: date to retrieve current date value in PostgreSQL in the following way – Now let us see some of the date-related functions that are available in PostgreSQL for date retrieval and manipulation. This is because we have mentioned the starting_date column of DATE datatype and having the default value of CURRENT_DATE that is the date at the movement when the record will be inserted according to the database server on which the value is inserted. We can see that today’s date i.e 7th of April 2020 is inserted as the value in the starting_date column of our table even when we haven’t mentioned it while inserting the record. Let us now check the contents of our table educba by firing the following SELECT command – SELECT * FROM educba
0 Comments
Leave a Reply. |