Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About

Tag: datetime

C#

How to get the Xth Day of the Week of the Year in C#

- 25.09.23 - ErcanOPAK comment on How to get the Xth Day of the Week of the Year in C#

Let’s say we want to find the date of the first Friday of the 1st month. GetFirstFridayOfMonth(01.01.2023) =>06.01.2023 (The first Friday after 01.01.2023 is 06.01.2023) public DateTime GetFirstFridayOfMonth(DateTime date) { DateTime fridayDate = new DateTime(date.Year, date.Month, 1); //Let’s assume 1st Friday can start on the 1st of the month while (fridayDate.DayOfWeek != DayOfWeek.Friday) { fridayDate […]

Read More
ASP.Net MVC / ASP.Net WebForms / C# / SQL

How to add default value for Entity Framework migrations for DateTime and Bool

- 19.06.22 - ErcanOPAK comment on How to add default value for Entity Framework migrations for DateTime and Bool

Just add defaultValue parameter in CreateTable method for property: public partial class TestSimpleEntity : DbMigration { public override void Up() { CreateTable( “dbo.SimpleEntities”, c => new { id = c.Long(nullable: false, identity: true), name = c.String(), deleted = c.Boolean(nullable: false, defaultValue: true), }) .PrimaryKey(t => t.id); } public override void Down() { DropTable(“dbo.SimpleEntities”); } } After that, run update-database -verbose command, […]

Read More
Reportviewer

How to display total sum of seconds in hh:mm:ss format in ReportViewer

- 27.07.21 - ErcanOPAK comment on How to display total sum of seconds in hh:mm:ss format in ReportViewer

=Format(DateAdd(“s”, Fields!MySecondsField.Value, “00:00:00”), “HH:mm:ss”)  

Read More
C#

How to Validate a DateTime in C#?

- 03.01.21 - ErcanOPAK comment on How to Validate a DateTime in C#?

DateTime myDate; if(DateTime.TryParse(txtBirthDate.Text, out myDate)) { //Valid Date } else { //Invalid Date }

Read More
ASP.Net MVC / ASP.Net WebForms / C#

Formatting a Nullable DateTime with ToString() in ASP.Net MVC

- 31.03.20 | 31.03.20 - ErcanOPAK comment on Formatting a Nullable DateTime with ToString() in ASP.Net MVC

Let’s say we have a Nullable DateTime named StartTime [DisplayFormat(DataFormatString = “{0:dd.MM.yyyy}”)] public Nullable<System.DateTime> StartTime { get; set; }

Read More
ASP.Net MVC / ASP.Net WebForms / C#

How to use Stopwatch in C#

- 22.12.19 - ErcanOPAK comment on How to use Stopwatch in C#

The Stopwatch object is often used to measure how long things take. One quick thing to remember here is that it will take the time for everything you do between starting and stopping it, so make sure you only put the actual code you want to time between those.

Read More
SQL

Date and Time Conversions in SQL Server

- 26.05.19 | 22.11.19 - ErcanOPAK comment on Date and Time Conversions in SQL Server

SQL Server provides a number of options you can use to format a date/time string. One of the first considerations is the actual date/time needed. The most common is the current date/time using getdate(). This provides the current date and time according to the server providing the date and time. If a universal date/time is needed, […]

Read More
December 2023
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
« Nov    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (704)
  • Get the First and Last Word from a String or Sentence in SQL (698)
  • How to select distinct rows in a datatable in C# (560)
  • Add Constraint to SQL Table to ensure email contains @ (455)
  • Average of all values in a column that are not zero in SQL (373)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (344)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (338)
  • Find numbers with more than two decimal places in SQL (325)
  • Confirm before process with ASPxButton in Devexpress (316)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (292)

Recent Posts

  • How to find a specific text string in a SQL Server Stored Procedure, Function, View or Trigger
  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github
  • How to display HTML components on the same line in CSS
  • How to insert results of a stored procedure into a temporary table
  • How to remove all non alphanumeric characters from a string in C#
  • How to get the Xth Day of the Week of the Year in C#

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (704)
  • Get the First and Last Word from a String or Sentence in SQL (698)
  • How to select distinct rows in a datatable in C# (560)
  • Add Constraint to SQL Table to ensure email contains @ (455)
  • Average of all values in a column that are not zero in SQL (373)

Recent Posts

  • How to find a specific text string in a SQL Server Stored Procedure, Function, View or Trigger
  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

© 2023 ErcanOPAK.com

Proudly powered by WordPress | Theme: Xblog Plus by wpthemespace.com