Questions tagged [date-formatting]

Date formatting is the process of displaying, handling or converting a calendar date to a specific format.

Wikipedia goes into good detail about various date formats in its Date format by country article:

Basic components of a calendar date for the most common calendar systems:

Y – Year
M – Month
D – Day

Order of the basic components:

B – Big-endian (year, month, day), e.g. 1996-04-22
L – Little-endian (day, month, year), e.g. 22.04.96 or 22/04/96
M – Middle-endian (month, day, year), e.g. 04/22/96

Specific formats for the basic components

yyyy – Four-digit year, e.g. 1996
yy – Two-digit year, e.g. 96
mm – Two-digit month, e.g. 04
m – one-digit month for months below 10, e.g. 4
mmm – three-letter abbreviation for month
mmmm – month spelled out in full
dd – two-digit day, e.g. 02
d – one-digit day for days below 10, e.g. 2

Separators of the components

"/" – Slash
"." – Dots or full stops
"-" – Hyphens or dashes
" " – Spaces
1459 questions
13
votes
7 answers

How To assign null values in MySql using VB.NET

I am not sure why VB makes everything such a pain. I have a fields which stores the date and time in the format required to store in MySQL database Dim AppDate As String = String.Empty If Not String.IsNullOrEmpty(Me.AppDate.Text.Trim) Then …
fireBand
  • 937
  • 6
  • 22
  • 42
11
votes
4 answers

In SQL Server, how to convert a date to a string in format M/D/YYYY? (no leading zeros, not MM/DD/YYYY)

Right now, my code has the following conversion for a date field: convert(varchar, Citation.PublishedOn, 101) However, that returns dates like 03/01/2010. The request was to have the dates display as 3/1/2010 (without the leading zeros, but with a…
thursdaysgeek
  • 7,260
  • 18
  • 72
  • 104
11
votes
2 answers

Angular material datepicker - select date only

I have a Material Datepicker from which I would like to only get date with no timestamp. Since my timezone is GMT+2, API always receives something like 03.04.2018 22:00:00 UTC, but I would like to save the dates in local. My datepicker: "Wed Apr 11…
mklfw
  • 111
  • 1
  • 4
11
votes
7 answers

When using jquery datepicker, what is the correct way to handle people typing in dates in different formats?

I have the following code: $('#MilestoneStartDate').datepicker({ dateFormat: 'dd M yy' }); and it all works fine if you use the mouse to click on a date in the popup to enter a date but if a person types in a date or pastes in a date into the…
leora
  • 163,579
  • 332
  • 834
  • 1,328
11
votes
3 answers

How do I specify date literal when writing SQL query from SQL Server that is linked to Oracle?

I have a SQL Server 12.0 database that is linked to an Oracle 12.1 database. I want to create a view in the SQL Server database that returns data from an Oracle table filtered by date. The Oracle table has an index on the date column. A query that…
Richard A
  • 2,682
  • 2
  • 21
  • 33
11
votes
2 answers

What exactly does trunc(date, 'IW')?

For my project I need to have an absolute numerical correspondence between days of the week and 1...7 values. As you probably know the association between days and numbers can vary according to the locale, for example in Germany Monday is 1 and…
Phate
  • 4,750
  • 10
  • 51
  • 98
11
votes
1 answer

Format code for a date with time zone in excel

I have date value with a time zone. 24 Nov 2005 GMT+05:30 What is the format code for this custom format in Excel? I tried dd MMM yyyy with z,zz,zzz, and Z but Excel ignores those options.
Farhana
  • 159
  • 1
  • 2
  • 9
11
votes
2 answers

Joda time - Parsing string throws java.lang.IllegalArgumentException

Shouldn't a String formatted with a specific DateTimeFormatter be able to be parsed using LocalDateTime.parse()? Test DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis() LocalDateTime ldt = new LocalDateTime() String val =…
user800014
11
votes
2 answers

Convert dd/MM/yyyy to MM/dd/YYYY

I need to convert "28/08/2012" to MM/dd/YYYY format that means "08/28/2012". How can I do that? I am using below code , but it threw exception to me. DateTime.ParseExact("28/08/2012", "ddMMyyyy", CultureInfo.InvariantCulture)
Lajja Thaker
  • 1,909
  • 8
  • 28
  • 52
11
votes
7 answers

SQL Server Datetime issues. American vs. British?

On my test DB, the dates are displayed in a DD/MM/YYYY format. By displayed I mean when you right click, open table in Management Studio, the returned data are displayed in a DD/MM/YYYY format. Funny thing is, when I write T-SQL to retrieve records,…
super9
  • 26,033
  • 36
  • 110
  • 168
10
votes
2 answers

Getting wrong data when using SimpleDateFormat.parse()

I am getting the strangest error, when trying to parse a string as a calendar. It seems that it messes up the Date object which I use to set the result calendar's time. The error is pretty inconsistent (or I see no logic in it). Can anyone point out…
Tegi
  • 708
  • 7
  • 14
10
votes
3 answers

How to convert date to datetime in Oracle?

i have a date in oracle with this format DD-MM-YYY and i want to convert it to datetime with this other format DD-MM-YYY HH24:MI how can i proceed? I've tried this but nothing is working : to_date(the_date,'DD-MM-YYY HH24:MI') and also…
Joel Patrick Ndzie
  • 109
  • 1
  • 1
  • 3
10
votes
1 answer

Is the Formatting Syntax of SimpleDateFormat a Java Invention?

Is the syntax of date-time format strings as defined in Java's SimpleDateFormat class (like "EEE, MMM d, ''yy" and such) an original Java invention, or is it based on some other syntax definition like ICU's or CLDR's?! Is anybody aware of work that…
ThomasH
  • 19,270
  • 9
  • 53
  • 57
10
votes
4 answers

Convert datetime.datetime object to days since epoch in Python

I've got a pandas.Series object that might look like this: import pandas as pd myVar = pd.Series(["VLADIVOSTOK 690090", "MAHE", NaN, NaN, "VLADIVOSTOK 690090", "2000-07-01 00:00:00"]) myVar[5] is parsed as a datetime.datetime object when the data…
brittenb
  • 5,849
  • 3
  • 30
  • 58
9
votes
2 answers

Error: Attempted to call method "format" on null context object

Spring-boot v1.4.1 Java v1.8 Thymeleaf v2.1.5. The following line of code in my view: which has syntax I am basing…
adam.shaleen
  • 773
  • 2
  • 8
  • 17