How do I convert SQL getdate() function into a string in dd/mm/yyyy format?
In order to convert a DateTime to a string, we can use CONVERT() and CAST() function. These functions are used to converts a value(of any datatype) into a specified datatype.
SQL Server GETDATE() Function The GETDATE() function returns the current database system date and time, in a 'YYYY-MM-DD hh:mm:ss. mmm' format.
Try:
select convert(varchar(10),getdate(),103)
There's more info on the different conversion codes here.
Use conversion code 103
convert(varchar, getdate(), 103)
this worked for me
replace(convert(char(11),getdate(),113),' ','-')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With