Ask a Question related to Dreamweaver AppDev, Design and Development.
-
darrel #1
SQL: can a date ONLY contain month/year info?
When using a SQL datetime field, is there a way to store ONLY the month and
year?
I have a situation where I need to store both month/year and month/day/year
data in the same column. Ie, some records will store the full date, some
will only be storing month/year.
Can the 'day' portion of date/time be null? Or can anyone think of a better
way to handle this?
Worst case, I may just tell the folks that they NEED to use a full
month/day/year and those that are just tracking month/year will have to deal
with a default day of '1'
-Darrel
darrel Guest
-
group by month/year
I have a table that has a column titled ArticleDate. I would like to group an output based only on the month and year. For instance, a link for... -
1210: Date could not be converted to month/day/year format
Hi, I got this error when downloading a table by "unload" order : 1210: Date could not be converted to month/day/year format It seems that a... -
Get Year, Month and the Day
It works fine but i read the date from a database and i need the year, month and day of this date not the system date. If you know how to seperate... -
Show" Last view... Day - Month - Date - Year on page.
Hello All; I have just added in a JavaScript function that show that Day - Month - Day - Year On my page. This is going for a look of Last... -
Sort - Month then day without year
How's about "Sort" Month / Day without year in birthday date field? Daniel R. Sloan -
Jon Spivey #2
Re: can a date ONLY contain month/year info?
Hi,
No a sql server datetime field must contain day month year and time - if
you miss out say the time sql server will add midnight. Does it have to a
datetime field? Why not make it a varchar and stick in month/year and
day/month/year as needed. If you needed to do something like sort by date
order you could use a case statement to stick a fictional day as needed and
then cast the field as datetime
You could insert say March 2005 (although not 3/2005) into a datetime field
but sql server will add 1 for the day so you'd end up with 1 March 2005 -
only trouble is you'd need another column to record whether the user
actually entered 1st March 2005 or just March 2005, this would be easy
enough but seems like making work for yourself
Jon
"darrel" <notreal@hotmail.com> wrote in message
news:d224vr$kif$1@forums.macromedia.com...> When using a SQL datetime field, is there a way to store ONLY the month
> and
> year?
>
> I have a situation where I need to store both month/year and
> month/day/year
> data in the same column. Ie, some records will store the full date, some
> will only be storing month/year.
>
> Can the 'day' portion of date/time be null? Or can anyone think of a
> better
> way to handle this?
>
> Worst case, I may just tell the folks that they NEED to use a full
> month/day/year and those that are just tracking month/year will have to
> deal
> with a default day of '1'
>
> -Darrel
>
>
Jon Spivey Guest
-
Taffydog #3
Re: SQL: can a date ONLY contain month/year info?
sql is limited in date handling only storing dates as yyyyy-mm-dd, however you
can format the date when displaying it in a table.
The syntax varies depending on the server technology used.
Using php you would display a date field in a table something like this
<?php echo makeDateTime($row_yourtable['date'], 'M j, Y'); ?>
this would display the date in the form of Jan 01, 2005
<?php echo makeDateTime($row_yourtable['date'], 'M, Y'); ?>
would display the date in the form of
Jan 2005
If you require the full month name change the M to F
Taffydog Guest
-
darrel #4
Re: can a date ONLY contain month/year info?
> Hi,
Hmm...that is an *excellent* point. This field won't ever be used for> No a sql server datetime field must contain day month year and time - if
> you miss out say the time sql server will add midnight. Does it have to a
> datetime field? Why not make it a varchar and stick in month/year and
> day/month/year as needed.
sorting or anything. Well...unless we use it for archiving. I'll have to
mull that over a bit. ;o)
and> If you needed to do something like sort by date
> order you could use a case statement to stick a fictional day as neededWell, that's what I was thinking...since some dates are m/y, but some are> then cast the field as datetime
m/d/y, that I'd just always have a day in there...it's not really a big deal
if the day is 'fake'.
-darrel
darrel Guest
-
darrel #5
Re: SQL: can a date ONLY contain month/year info?
> sql is limited in date handling only storing dates as yyyyy-mm-dd, however
youThanks, Taffy!> can format the date when displaying it in a table.
-Darrel
darrel Guest



Reply With Quote

