Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
dear sir/ma'am,
 

i fetch time from table as
 
ds.tables("che").rows(0).item("time")
 
value i got as
 
01/01/1900 06:00:00
 
sir i want to check this value lie with in an interval
 
06:00:00 to 08:00:00
how can i do it,
help ,me regarding this
Posted 9-May-13 20:09pm
ankur7891.4K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

How about something simple like this:
 
if ((ds.tables("che").rows(0).item("time") >= "01/01/1900 06:00") and (ds.tables("che").rows(0).item("time") <= "01/01/1900 08:00")) then
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt_table = DateTime.Now;
 
            Console.WriteLine(dt_table);
 
            DateTime dt_compare_1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 0, 0);
            DateTime dt_compare_2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0);
 
            if (dt_table > dt_compare_1 && dt_table < dt_compare_2)
                Console.WriteLine("Time is between 11 and 12 o'clock");
            else
                Console.WriteLine("Time is not between 11 and 12 o'clock");
 
            Console.ReadKey();
        }
    }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt_table = DateTime.Now;
 
            Console.WriteLine(dt_table);
 
            DateTime dt_compare_1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 0, 0);
            DateTime dt_compare_2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0);
 
            if (dt_table > dt_compare_1 && dt_table < dt_compare_2)
                Console.WriteLine("Time is between 11 and 12 o'clock");
            else
                Console.WriteLine("Time is not between 11 and 12 o'clock");
 
            Console.ReadKey();
        }
    }
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100