Re: How to Get Year/Month/Date of a DateTime Column by Column.Expr by LIYing
LIYing
Thu Feb 24 19:41:03 CST 2005
Thank you for your hint.
I hope to solve this problem in ADO.net instead of in my presentation layer.
If this problem is difficult, is it possible to Get Year/Month/Date of a
DateTime Column by Column.Expression when we know the DataTable's Locale
(Culture)?
For there are so many kinds of Cultures, it is still a difficult task.
"John Smith" wrote:
> Why dont you do the following.
>
> 1. Have a column of type datetime or smalldatetime in your database.
> 2. Adjust your Regional Settings to match your date requirements (YY/MM/DD)
> in Windows Control Panel
> 3. When you read, do the following
>
> MyTextBox.Text = CDate(row("MyDateTimeRow")).ToShortDateString
>
> If your need to manipulate individual elements, you can use, for example:
>
> ...... = CDate(row("MyDateTimeRow")).Year ' or Month or Day, etc ...
>
> If your column supports null values, check before the convertion:
>
> ..... = CStr(iif(isDBNull(row("MyDateTimeRow")), "Empty Date",
> row("MyDateTimeRow").toShortDateString))
>
> "LI Ying" <LI Ying@discussions.microsoft.com> wrote in message
> news:DFAFDE2C-DE61-4540-9A63-A24DE94B22A9@microsoft.com...
> >
> > I mean to create a new column with Integer type, which is defined by its
> > expression to be Year/Month/Date of a DateTime Column.
> >
> > Of course, It is simple to define such a new column by
> > Substring(Convert(DateTimeColumn,"System.String"),x,y) to get
> > Year/Month/Date of DateTime Column if we know the DataTable.Local when we
> > code the expression.
> >
> > If not, how to do?
> >
> > Any suggestions are welcome.
> >
> > LI Ying
>
>
>