473,803 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i want to convert datetime into date only to get values from db

1 New Member
hi all i am newly graduate and started my first job.......i am geting problem to convert datetime into date only , i am trying to get values from sqlserver table with comparison of date. i am using c# what i am doing is:
switch (completed)
{
case 0 : if(date<DateTim e.Today)
e.Cell.Text += "<tr><td style=\"font-size:8px;color: red;line-height:12px;ver tical-align:center;\" >";
e.Cell.Text += "<tr><td style=\"font-size:8px;color: blue;line-height:12px;ver tical-align:center;\" >";
break;
case 1 : e.Cell.Text += "<tr><td style=\"font-size:8px;color: green;line-height:10px;ver tical-align:center;\" >";
break;
}

in completed column either i have 0 or 1 . 0 i am using to get two values with comparison of date and 1 is showing true.

hopefully you will help me to solve this problem

waiting
Oct 1 '07 #1
1 2047
Plater
7,872 Recognized Expert Expert
Well I made your code a little "neater" to have a better look at it.
What is you question exactly? I see that you are switching on a "completed" variable. if completed=0 then check to see if "date" was before today's date. if it is, you add some html data. Then, regardless of the outcome of that if statement, you add MORE html data (creating broken tags and incorrect html).
if completed==1 then you just add one set of html data.
Expand|Select|Wrap|Line Numbers
  1. switch (completed)
  2. {
  3.    case 0 : 
  4.       if(date<DateTime.Today)
  5.       {
  6.          e.Cell.Text += "<tr><td style=\"font-size:8px;color:red;line-height:12px;vertical-align:center;\">";
  7.       }
  8.       e.Cell.Text += "<tr><td style=\"font-size:8px;color:blue;line-height:12px;vertical-align:center;\">";
  9.       break;
  10.    case 1 : 
  11.       e.Cell.Text += "<tr><td style=\"font-size:8px;color:green;line-height:10px;vertical-align:center;\">";
  12.       break;
  13. }
  14.  
Oct 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3249
by: Sorisio, Chris | last post by:
Ladies and gentlemen, I've imported some data from a MySQL database into a Python dictionary. I'm attempting to tidy up the date fields, but I'm receiving a 'mx.DateTime.Error: cannot convert value to a time value' error. It's related to glibc returning an error to a pre-1970 date, I think. My question: /how/ do I go through the Python direction I've created to remove the pre-1970 date objects? Ideally, I would be able to iterate...
19
7294
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
5
16337
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
4
15805
by: v0lcan0 | last post by:
I’m trying to cast and integer type to a varchar and then concatenate two varchar and ’01’ and convert it into datetime with the following code: CONVERT(datetime, { fn CONCAT({ fn CONCAT(CAST(PeriodYear AS varchar), CAST(PeriodMonth AS varchar)) }, ’01’) }, 112) AS date It gives an error saying syntax error converting datetime from character string.
6
6736
by: Richard | last post by:
Hi all, Hope everybody is having an OK monday?!!? Quick question, I have a database in which the dates are stored as longs. I think the original program was VB and the dates were just cast to long before being saved to the database. I now need to convert these long values back into datetime values.
15
9078
by: JenHu | last post by:
Hi expert, I have a data field (birthdate) contains a datetime datatype (mm/dd/yyyy), how can I convert to mmdd?? say, the birthday is 8/1/1979 and convert to mmdd DOB = DS.Tables("AcctInfoTble").Rows(3)("BRTHDATE") strResult.Insert(12, DOB.PadLeft(37, " ")) ---------------------------------------------------------------------------------------------------
10
4481
by: Philip Wagenaar | last post by:
I have some code to convert a date to the unixdatetime representation (number of seconds since 1970). Only problem is that it only counts from the whole day, it ignores the times part. So convert 1/1/1970 and 1/1/1970 8:00:00 AM both return 0 but the last should return 28800. My code: Try Dim dte As DateTime dte = DateTime.Parse(CmdArgs(1)) Console.WriteLine(DateDiff(DateInterval.Second,
17
71463
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
0
1727
by: feeblemind | last post by:
Hi everyone, I am having problem/troubles with creating an sql inline statement for our application. How do I create a statement/query that selects list of servers with defined date ranges, but once a server of the same name has date ranges within the date range of another, I will have to get the date range that contains them all. For easy understanding here's a snapshot of data (the Before and After screenshots). BEFORE: Id ServerName...
0
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10292
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.