Click here to Skip to main content
15,897,291 members
Home / Discussions / C#
   

C#

 
AnswerRe: Different string conversions to integer Pin
Guffa4-May-06 3:39
Guffa4-May-06 3:39 
AnswerRe: Different string conversions to integer Pin
J4amieC4-May-06 3:43
J4amieC4-May-06 3:43 
AnswerRe: Crystal report Pin
V.4-May-06 3:30
professionalV.4-May-06 3:30 
QuestionRemove cache programmatically Pin
AmitSumit4-May-06 1:45
AmitSumit4-May-06 1:45 
AnswerRe: Remove cache programmatically Pin
Guffa4-May-06 4:19
Guffa4-May-06 4:19 
QuestionXML Data Binding Pin
Kyawgyi4-May-06 1:17
Kyawgyi4-May-06 1:17 
AnswerRe: XML Data Binding Pin
sathish s4-May-06 1:24
sathish s4-May-06 1:24 
QuestionCasting string to Date Pin
Mark064-May-06 1:11
Mark064-May-06 1:11 
Hey everyone,

I have an sql database with a table field which is a nvarchar. But the field actually contains a date and time of an event, for each record.

Im trying to count up all the events that occurred today. Here's my code:
            // Loop through each record<br />
            for (int i = 0; i < table.Rows.Count; i++)<br />
            {<br />
                // Check there isnt a null<br />
                if (table.Rows[i][0] != null)<br />
                {<br />
                    thedate = (DateTime)table.Rows[i][0];<br />
<br />
                    if ((DateTime)table.Rows[i][0] == DateTime.Now)<br />
                        count += 1;<br />
                }<br />
            }<br />


2 problems. Firstly, the line thedate = ...., fails everytime. It will not cast and reports an exception about failing to assign infinity. How else can I convert the string field to a date object?

Also, the field contains a date and time. I need to compare todays date with that field, excluding the actual time. Is that possible?


Any help gratefully appreciated


Andy
AnswerRe: Casting string to Date Pin
sathish s4-May-06 1:22
sathish s4-May-06 1:22 
GeneralRe: Casting string to Date Pin
Mark064-May-06 1:46
Mark064-May-06 1:46 
AnswerRe: Casting string to Date Pin
alexey N4-May-06 1:23
alexey N4-May-06 1:23 
QuestionDataGridColumnStyle in WinForms Pin
Sreeroop4-May-06 0:36
Sreeroop4-May-06 0:36 
AnswerRe: DataGridColumnStyle in WinForms Pin
MCSD-Gandalf4-May-06 2:26
MCSD-Gandalf4-May-06 2:26 
GeneralRe: DataGridColumnStyle in WinForms Pin
Sreeroop4-May-06 20:48
Sreeroop4-May-06 20:48 
QuestionHow to run application from Byte[] Pin
Dima Filipiuk4-May-06 0:27
Dima Filipiuk4-May-06 0:27 
AnswerRe: How to run application from Byte[] Pin
alexey N4-May-06 0:35
alexey N4-May-06 0:35 
Questionhow to Save Matrix Pin
Greeky4-May-06 0:19
Greeky4-May-06 0:19 
AnswerRe: how to Save Matrix Pin
Guffa4-May-06 1:09
Guffa4-May-06 1:09 
GeneralRe: how to Save Matrix Pin
Greeky4-May-06 1:37
Greeky4-May-06 1:37 
AnswerRe: how to Save Matrix Pin
Guffa4-May-06 2:02
Guffa4-May-06 2:02 
GeneralRe: how to Save Matrix Pin
Greeky4-May-06 6:24
Greeky4-May-06 6:24 
QuestionDynamicly putting checkboxes on a form HELP Pin
Arjen van der Have3-May-06 23:49
Arjen van der Have3-May-06 23:49 
Questionscroll bar in a Custom control Pin
javierCVB3-May-06 23:43
javierCVB3-May-06 23:43 
QuestionDateTimePicker Pin
V.3-May-06 23:42
professionalV.3-May-06 23:42 
AnswerRe: DateTimePicker Pin
J4amieC3-May-06 23:54
J4amieC3-May-06 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.