C# Program to Display the Next Day

Ankith Reddy
Updated on 22-Jun-2020 14:12:50

3K+ Views

To display the next day, use the AddDays() method and a value +1 to get the next day.Firstly, use the following to get the current day −DateTime.TodayNow, add 1 to the AddDays() method to get the next day −DateTime.Today.AddDays(1)The following is the code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo {    public static void Main() {       Console.WriteLine("Today = {0}", DateTime.Today);       Console.WriteLine("Previous Day = {0}", DateTime.Today.AddDays(-1));       Console.WriteLine("Next Day (Tomorrow) = {0}", DateTime.Today.AddDays(1));    } }OutputToday = 9/4/2018 12:00:00 AM Previous Day = 9/3/2018 12:00:00 AM Next Day (Tomorrow) = 9/5/2018 12:00:00 AM

C# Program to Display the Number of Days in a Month

Arjun Thakur
Updated on 22-Jun-2020 14:12:25

739 Views

Use the DaysInMonth to display the number of days in a month.Add the year and month as a parameter for the DaysInMonth() method −DateTime.DaysInMonth(2018, 8);The following is an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo {    public static void Main() {       Console.WriteLine("Today = {0}", DateTime.Today);       int num_days = DateTime.DaysInMonth(2018, 8);       Console.WriteLine("Days in August: "+num_days);    } }OutputToday = 9/4/2018 12:00:00 AM Days in August: 31

Timespan From Methods in C#

Chandu yadav
Updated on 22-Jun-2020 14:12:03

170 Views

The TimeSpan.From methods include FromDays, FromHours, FromMinutes, etc.To get the TimeSpan for all the methods// Days TimeSpan t1 = TimeSpan.FromDays(1); // Hours TimeSpan t2 = TimeSpan.FromHours(1); // Minutes TimeSpan t3 = TimeSpan.FromMinutes(1);The following is the code that works on all the TimeSpan methods −Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan t1 = TimeSpan.FromDays(1);       TimeSpan t2 = TimeSpan.FromHours(1);       TimeSpan t3 = TimeSpan.FromMinutes(1);       Console.WriteLine(t1);       Console.WriteLine(t2);       Console.WriteLine(t3);    } }Output1.00:00:00 01:00:00 00:01:00

Generate Days from Range of Dates Using MySQL Views

karthikeya Boyini
Updated on 22-Jun-2020 14:11:56

350 Views

To illustrate it we are creating the following views −mysql> CREATE VIEW digits AS     -> SELECT 0 AS digit UNION ALL     -> SELECT 1 UNION ALL     -> SELECT 2 UNION ALL     -> SELECT 3 UNION ALL     -> SELECT 4 UNION ALL     -> SELECT 5 UNION ALL     -> SELECT 6 UNION ALL     -> SELECT 7 UNION ALL     -> SELECT 8 UNION ALL     -> SELECT 9; Query OK, 0 rows affected (0.08 sec) mysql> CREATE VIEW numbers AS SELECT ones.digit + ... Read More

C# Program to Add Two TimeSpan

George John
Updated on 22-Jun-2020 14:11:39

685 Views

Firstly, set two TimeSpans −TimeSpan t1 = TimeSpan.FromMinutes(1); TimeSpan t2 = TimeSpan.FromMinutes(2);To add it, use the Add() method −TimeSpan res = t1.Add(t2);ExampleUsing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan t1 = TimeSpan.FromMinutes(1);       TimeSpan t2 = TimeSpan.FromMinutes(2);       Console.WriteLine("First TimeSpan: "+t1);       Console.WriteLine("Second TimeSpan: "+t2);       // Adding       TimeSpan res = t1.Add(t2);       Console.WriteLine("Resultant TimeSpan: "+res);    } }

Write PHP Script Using MySQL JOINS to Join Two Tables

mkotla
Updated on 22-Jun-2020 14:11:18

5K+ Views

We can use the syntax of MySQL JOIN for joining two tables into the PHP function – mysql_query(). This function is used to execute the SQL command and later another PHP function – mysql_fetch_array() can be used to fetch all the selected data.To illustrate it we are having the following example −ExampleIn this example, we are using two MySQL tables which have the following data −mysql> SELECT * FROM tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ | mahran          |      20        | | mahnaz          |     ... Read More

Chash Ticksper Constants

Ankith Reddy
Updated on 22-Jun-2020 14:11:18

245 Views

TicksPer constants in C# have TicksPerDay, TicksPerHour, TicksPerMinute, TicksPerSecond, and TicksPerMillisecond constants. A millisecond consists of 10,000 ticks.Here are the TicksPer constants −TimeSpan.TicksPerDay TimeSpan.TicksPerHour TimeSpan.TicksPerMinuteExample Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       // TicksPer constant       Console.WriteLine(TimeSpan.TicksPerDay);       Console.WriteLine(TimeSpan.TicksPerHour);       Console.WriteLine(TimeSpan.TicksPerMinute);    } }Output864000000000 36000000000 600000000

Exact Representation of No Time in Chash

Arjun Thakur
Updated on 22-Jun-2020 14:10:56

102 Views

Use the TimeSpan.Zero to represent the exact representation of no time i.e −00:00:00Set an object for TimeSpan −TimeSpan ts;Now, the TimeSpan.Zero is used to display no time −TimeSpan ts = TimeSpan.Zero;Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = TimeSpan.Zero;       Console.WriteLine(ts);    } }Output00:00:00

Format Timespan in C#

Chandu yadav
Updated on 22-Jun-2020 14:10:36

3K+ Views

You can format a TimeSpan in the hh: mm: ss format in C#.Firstly, set the TimeSpan −TimeSpan ts = new TimeSpan(9, 15, 30);To format TimeSpan −{0:hh\:mm\:ss}The following is the code −Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(9, 15, 30);       Console.WriteLine("{0:hh\:mm\:ss}", ts);    } }Output09:15:30

C# Program to Find the Index of an Element in a List

karthikeya Boyini
Updated on 22-Jun-2020 14:10:03

1K+ Views

Set a list and add elements −List val = new List(); // integer elements val.Add(35); val.Add(55); val.Add(68);Let’s say now we need to find the index of element 68. For that, use the IndexOf() method −int index = val.IndexOf(68);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       List val = new List();       // integer elements       val.Add(35);       val.Add(55);       val.Add(68);       // finding the index of element 68       int index = val.IndexOf(68);       Console.WriteLine(index);    } }Output2

Advertisements