It broadly reflects the picture across the UK, where life expectancy for males has dropped for the first time since current records began.
Statisticians have blamed the impact of the coronavirus pandemic, but said the figures do not necessarily mean those born in recent years will go on to live a shorter life.
Office for National Statistics data shows that in Midlothian, a boy born between 2018 and 2020 is expected to live until they are 77.4 years old, down from 77.9 in 2015-17.
Meanwhile, life expectancy from birth for females fell from 81.6 to 81.2 between the two periods.
Across the UK, a baby boy born in 2018-20 is expected to live until he is 79, down from 79.2 for the 2015-17 period, while a girl born in 2018-20 is estimated to live for 82.9 years, the same as in 2015-17.
The figures reflect the impact of the coronavirus pandemic, which led to a greater number of deaths than usual last year, the ONS said.
Pamela Cobb, of the ONS centre for ageing and demography, said: “Life expectancy has increased in the UK over the last 40 years, albeit at a slower pace in the last decade.
“However, the coronavirus pandemic led to a greater number of deaths than normal in 2020.
“Consequently, in the latest estimates, we see virtually no improvement in life expectancy for women, while for men life expectancy has fallen back to levels reported for 2012 to 2014.
“This is the first time we have seen a decline when comparing non-overlapping time periods since the series began in the early 1980s.”
The ONS also said the figures did not necessarily mean a baby born between 2018 and 2020 will live a shorter life, with the estimates based on the "unusually high" levels of deaths.
“Once the coronavirus pandemic has ended and its consequences for future mortality are known, it is possible that life expectancy will return to an improving trend in the future," Ms Cobb added.
Across the UK, changes in life expectancy varied widely. The North East saw the biggest drop in male life expectancy between 2015-17 and 2018-20 – down 17 weeks to 77.6 years – while Northern Ireland saw the largest rise, up 12 weeks to 78.7 years.
In Scotland, the figure fell by 11 weeks to 76.8 years.
For female life expectancy, Wales and the West Midlands saw the biggest drops in life expectancy, down 10 weeks to 82.1 and 82.5 years respectively.
Meanwhile, at the other end of the spectrum, in the South West, female life expectancy rose 17 weeks to 84.1 years.
In Scotland, the figure rose by five weeks to 81.1 years.
The ONS said this was another example of the impact of coronavirus in 2020, with the South West recording lower male and female Covid-19 mortality rates than other regions.