c# current date in yyyy-MM-dd format

c# current date in yyyy-MM-dd format

Hi,

How to get the current date in the format like 2021-01-12?

I have to get the date into Year-Month-Date format. In c# how to get current date in yyyy-mm-dd format?

Thanks

View Answers

April 18, 2021 at 5:55 AM

Hi,

You can use the following code:

var dateString = DateTime.Now.ToString("yyyy-MM-dd");
Console.WriteLine(dateString );

Above code will give date into 2021-01-21 format (yyyy-MM-dd).

I this example you have to give "MM" in the uppercase.

Hope this helps you.

Thanks

Ads









Related Tutorials/Questions & Answers:
c# current date in yyyy-MM-dd format
format. In c# how to get current date in yyyy-mm-dd format? Thanks   ...c# current date in yyyy-MM-dd format  Hi, How to get the current...("yyyy-MM-dd"); Console.WriteLine(dateString ); Above code will give date
How to format current date into yyyy-mm-dd in Java
How to format current date into yyyy-mm-dd in Java  Hi, I have requirement to format the date into yyyy-MM-dd format for inserting it into MySQL...-dd"); formats the date into yyyy-MM-dd format. the MM is used for getting
Advertisements
get current date in java in yyyy mm dd hh mm ss format
get current date in java in yyyy mm dd hh mm ss format  Hi, I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  
validationrule for date as format yyyy-mm-dd in drools
validationrule for date as format yyyy-mm-dd in drools  Please give... format yyyy-mm-dd: How i write the validation rule for date as a format yyyy-mm-dd...("outofServiceStartDate", "stmpOutOfServiceStartDateInvalid", "Please use the format yyyy-mm-dd
How to convert date to string in Java in yyyy-mm-dd format
to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... it to yyyy-mm-dd String format. Here is Java example for converting String Date... convert date to yyyy-mm-dd format */ public class DateToStringConversion
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... java.util.Date; /* * Example of formatting date in Java * from yyyy-mm-dd formaat
how to format date from yyyy-mm-dd to dd-mm-yyyy
how to format date from yyyy-mm-dd to dd-mm-yyyy  <!DOCTYPE html... to calculate the nos. of days between two dates, the date format is in "yyyy-mm-dd", so what i want is in "dd-mm-yyyy" format. So, how to change it? I would be much
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string date into the date format. How to convert string to date from format yyyy-mm-dd
convert yyyy-mm-dd hh mm ss to date in sql
convert yyyy-mm-dd hh mm ss to date in sql  Hi, How to convert yyyy-mm-dd hh mm ss to date in sql? Thanks   Hi, You should use following code in SQL DATE_FORMAT(STR_TO_DATE(my_date, "%Y/%m/%d %H:%i:%s.%f"), "%Y-%m
Mysql Date Expression
a format  'YYYY-MM-DD' and 'HH.MM.SS'. Timestamp columns are displayed...;   mysql> select current_timestamp() as Date; Output... to return the current date and time as Date fieldname. mysql>
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
Mysql Date Type
' records in 'yyyy-mm-dd' format. select emp_dob from employee: The select query return the emp_dob  records in "yyyy-mm-dd" format. The Date Type...; Mysql Date Type is used to show the date in "yyyy-mm-dd" format.The
java format date
java format date  Hi, How can I format the date in the following pattern? yyyy-MM-dd   import java.util.*; import java.text.*; class...-MM-dd"); String formattedDate=sdf.format(date
JDBC : Current Date
() functions  return the current date in format 'YYYY-MM-DD'. CURRENT... as a value in 'YYYY-MM-DD HH:MM:SS' SYSDATE()  : It returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' . Example
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
String to Date format
SimpleDateFormat("yyyy-MM-dd"); String formattedDate=sdf.format(date...("yyyy-MM-dd"); String formattedDate=sdf.format(date...String to Date format  My Date format is String Eg(Jan 20 2011
date format to be updated with current date time
date format to be updated with current date time  package LvFrm...; JButton b1,b2; //for date month year entry String strD[]={"Day","1...); /*Icon i=new ImageIcon("file:\\C:\\Documents%20and%20Settings\\All%20Users
Simple date formatter example
into the "yyyy-MM-dd HH:mm:ss" format. formatter = new SimpleDateFormat... we have formatted the date into  "yyyy-MM-dd" format. Here... formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate
Get current Date and Time
dateformat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); Date date=new Date... DateFormat dateformat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"... DateFormat dateformat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calender cal
How to convert current date to dd mm yyyy format in Java?
How to convert current date to dd mm yyyy format in Java?  Hi, How to convert current date to dd mm yyyy format in Java? In my program I have to display the current date in the dd-mm-yyyy format to user on the website. How
How to convert current date to mm dd yyyy format in Java?
How to convert current date to mm dd yyyy format in Java?  Hi, How to convert current date to mm dd yyyy format in Java? Share me the program... for converting current date into MM-dd-yyyy format. Here is full code: package
JDBC: Get current Date and Time Example
in the format 'YYYY-MM-DD' You can get current date by writing ... you can call CURTIME(). It returns current time in the format of 'HH:MM:SS...JDBC: Get current Date and Time Example In this section, you will learn how
Insert current date into MYSQL database
the date in MySQL is by using DATE and the proper format of DATE is: YYYY-MM-DD...Insert current date into MYSQL database In this tutorial, you will learn how to insert current date into database. In most of the applications
Mysql Date and Time
a date time format Query in different ways. now ( )  :The below Query return you the current date in yyyy-mm-dd and time in hh:mm:ss. Query for displaying current date and time:-          
struts2.2.1 date Format example
;Date Format(EEEE yyyy-MM-dd):</b><br/><br/> <s:date...; <b>Date Format (EEEE MM/dd/yyyy hh:mm AM/PM):</b><br/><.../yyyy 'at' hh:mm a" /> <hr> <b>Date Format (EEEE dd-MMM
Iphone Current Date Application
Iphone Current Date Application  Hi, I am a beginner in the mobile web application segment. How can i develop Iphone Current Date Application. I need the online help guide or example about iphone current date format. Thanks
javascript current date and time.
write new Date() it shows the current date in standard format with current day,date,time and GMT.You can have your own format...javascript current date and time.  How can we display current date
Mysql Date Select
you easy to understand how to get the current date from your database. The SELECT DATE ('YYYY-MM-DD') is used to return the current selected date. SELECT DATE... Mysql Date Select      
Mysql Date Format codes
in dd-mm-yy. mysql> select date_format(now(),'%e-%m-%y')as Date... Mysql Date Format codes       The Tutorial illustrate an example from 'Mysql date format
Mysql Date Format Convert
Mysql Date Format Convert       You already Know with the Query to find the current date and time. Now, we help you to convert the Mysql Date Format Conversion into other

Ads