Friday, May 29, 2020

Convert JD Edwards Julian Date to Calendar date in Excel Formula

JD Edwards Julian Date Converter in EXCEL Formulas

Formula to convert a Calendar date to JDE Julian date:
 =CONCAT(YEAR(A1)-1900,RIGHT(CONCAT("000",DAYS(A1,DATE(YEAR(A1),1,1))+1),3))

Formula to convert JD Edwards Julian date to a Calendar date:
=DATE(LEFT(A1,3),1,1)+(RIGHT(A1,3)-1)

Wednesday, May 13, 2020

QTD quarter date from and to

DECLARE @tDate DATETIME
SET @tDate = GETDATE()
 
SELECT @tDate AS 'Input Date',
  DATEADD(q, DATEDIFF(q, 0, @tDate ), 0)
                        AS 'frmDate',      
  DATEADD(d, -1, DATEADD(q, DATEDIFF(q, 0, @tDate ) + 1, 0))
                        AS 'toDate'


Tuesday, May 5, 2020

Get the size of all database in a SQL-Server

    SELECT DB_NAME(database_id) AS DatabaseName,
           sum((size * 8.0) / 1024.0) SizeMB
    FROM sys.master_files
    WHERE DB_NAME(database_id) in(SELECT name FROM sys.databases )
group by DB_NAME(database_id)
order by 1