Localhost Site not reached if web application runs.
Solution: Go to C:\Windows\System32\drivers\etc
Open 'host' File
Add '127.0.0.1 http://localhost:54499/'
Localhost Site not reached if web application runs.
Solution: Go to C:\Windows\System32\drivers\etc
Open 'host' File
Add '127.0.0.1 http://localhost:54499/'
Function IN SQL:
-
--SELECT [dbo].[GetYearDuration] (REPLACE(CONVERT(Date,e.DateOfBirth,103),' ','-') , REPLACE(CONVERT(Date,e.FirstJoiningDate,103),' ','-') ) as JoiningAge
--FROM Employee e
--WHERE e.EmployeeId = 3734
--SELECT [dbo].[GetDurationYear_Month_Day]('06 June, 1985', '04 July, 2020')
--SELECT [dbo].[GetDurationYear_Month_Day]('01 April, 1960', '26 March, 1986')
ALTER FUNCTION [dbo].[GetDurationYear_Month_Day]
(
@FromDate1 nvarchar(20), @ToDate1 nvarchar(20)
)
RETURNS NVARCHAR(300)
AS
BEGIN
Declare @Message NVARCHAR(300)
if isDate(@FromDate1) = 1 and isDate(@ToDate1) = 1
BEGIN
Declare @FromDate DATETIME, @ToDate DATETIME
SET @FromDate = @FromDate1
SET @ToDate = @ToDate1
DECLARE @date datetime, @tmpdate datetime, @years int, @months int, @days int
Declare @currentdatetime datetime
--SELECT @date = '15-Jun-1986'
set @date = @FromDate
set @currentdatetime = @ToDate
--SELECT
-- @date = REPLACE(CONVERT(Date,e.DateOfBirth,103),' ','-'),
-- @currentdatetime = REPLACE(CONVERT(Date,e.FirstJoiningDate,103),' ','-')
-- FROM Employee as e WHERE e.EmployeeId = 26380 --12390
SELECT @tmpdate = @date
SELECT @years = DATEDIFF(yy, @tmpdate, @currentdatetime) - CASE WHEN (MONTH(@date) > MONTH(@currentdatetime)) OR (MONTH(@date) = MONTH(@currentdatetime) AND DAY(@date) > DAY(@currentdatetime)) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(yy, @years, @tmpdate)
SELECT @months = DATEDIFF(m, @tmpdate, @currentdatetime) - CASE WHEN DAY(@date) > DAY(@currentdatetime) THEN 1 ELSE 0 END
SELECT @tmpdate = DATEADD(m, @months, @tmpdate)
SELECT @days = DATEDIFF(d, @tmpdate, @currentdatetime)
SET @Message = CAST(@years AS VARCHAR(4)) + '-' + CAST(@months AS VARCHAR(4)) + '-' + CAST(@days AS VARCHAR(4))
END -- END if
ELSE
BEGIN
SET @Message = 'Problem With Date:GetDurationYear_Month_Day'
END
RETURN @Message;
END
Javascript Code:
let EPOCH = new Date(0);
let EPOCH_YEAR = EPOCH.getUTCFullYear();
let EPOCH_MONTH = EPOCH.getUTCMonth();
let EPOCH_DAY = EPOCH.getUTCDate();
var dob = document.getElementById("BirthDate").value;
var birthDate = new Date(dob);
const diff = new Date(Date.now() - birthDate.getTime());
var years = Math.abs(diff.getUTCFullYear() - EPOCH_YEAR);
var months = Math.abs(diff.getUTCMonth() - EPOCH_MONTH);
var days = Math.abs(diff.getUTCDate() - EPOCH_DAY);
$("#Result").html(years + " year(s) " + months + " month(s) " + days + " and day(s)").css("color", "red");;
HTML:::
<div class="col-md-3">
<div class="form-group">
@Html.LabelFor(model => model.BirthDate, htmlAttributes: new { @class = "control-label", @autocomplete = "off" })<span style="color:red; font-size:15px;"> * </span>
<div style="margin:.1%;" id="Result"> </div>
@Html.EditorFor(model => model.BirthDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.BirthDate, "", new { @class = "text-danger" })
</div>
</div>
Reference: https://dev.to/code_mystery/javascript-age-calculator-calculate-age-from-date-of-birth-o9b
---
declare
@InitialData Table(
RowNum int IDENTITY(1,1) NOT NULL ,
EmployeeCode nvarchar(20)
)
INSERT INTO @InitialData
SELECT [Employee Code] FROM NXTRPTEmployeeProfile WHERE [daysIN Zone Office] is NULL
DECLARE @RowSl INT
,@Count INT
SET @RowSl = 1
SET @Count = (SELECT COUNT(*) FROM @InitialData)
WHILE @RowSl <= @Count
BEGIN
declare @currentEmployee varchar(20)
SELECT @currentEmployee = [EmployeeCode] FROM @InitialData WHERE RowNum = @RowSl
Update NXTRPTEmployeeProfile SET [daysIN Zone Office] = dbo.GetZoneOfficeDurationKF1Days(@currentEmployee)
WHERE [Employee code] = @currentEmployee
SET @RowSl += 1
END -- End While
Windows Screen Record WindowsKey+ Alt + R Recording Starts.