• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

storing mm/yyyy date format in asp.net

Hi, I am storing date formats in month and year only (mm/yyyy).
I am struggling on placing validation for it and storing in the above format. Any suggestion?

thank you
0
shpresa
Asked:
shpresa
4 Solutions
 
dsackerContract ERP Admin/ConsultantCommented:
Change it temporarily to "mm/01/yyyy", see if it passes IsDate (or similar) tests, then lose the /01. :)
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
Store it as YYYYMMDD in the database but display it any way you want in your screen. It is a bad practice to store date as string.

For example, '20070212' ymd is language-neutral only for the data types DATE, DATETIME2, and DATETIMEOFFSET.
0
 
Scott PletcherSenior DBACommented:
Use YYYYMM.  The problems with MM/YYYY are:
1) won't sort correctly
2) wasted space for the '/' -- never store editing chars in the db
3) can't do date math on it; YYYYMM has the same problem, but it's more easily fixed.  If you might need to ever do date math on the value, store it as YYYYMMDD.
0
 
PortletPaulfreelancerCommented:
Use a date column (storage 3 bytes). You get the needed validation built in, you can sort it, you can do proper date range filters using it and date arithmetic. You can output it as mm/yyyy if you want to.

Just assume the day is always 01
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
shpresa, do you still need help with this question?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now